/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSkyRoom.bridge.major;

import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import ru.jSkyRoom.interfaces.major.Keyword;
import ru.jSkyRoom.interfaces.major.Light;
import ru.jSkyRoom.interfaces.major.MagicEffect;
import ru.jSkyRoom.interfaces.major.Major;
import ru.jSkyRoom.interfaces.major.Perk;
import ru.jSkyRoom.interfaces.major.Projectile;
import ru.jSkyRoom.interfaces.major.Spell;
import ru.jSkyRoom.interfaces.stub.Art;
import ru.jSkyRoom.interfaces.stub.DualCastArt;
import ru.jSkyRoom.interfaces.stub.EffectShader;
import ru.jSkyRoom.interfaces.stub.Explosion;
import ru.jSkyRoom.interfaces.stub.ImageSpaceMod;
import ru.jSkyRoom.interfaces.stub.ImpactSet;
import ru.jSkyRoom.interfaces.stub.JSkyScriptPackage;
import skyproc.Condition;
import skyproc.FormID;
import skyproc.MGEF;
import skyproc.MGEF.SpellEffectFlag;
import skyproc.ScriptPackage;
import skyproc.genenums.ActorValue;
import skyproc.genenums.CastType;
import skyproc.genenums.DeliveryType;
import skyproc.genenums.SoundVolume;

/**
 *
 * @author Rakev
 */
public class MagicEffectBridge extends DescriptionedMajorBridge<MGEF> implements MagicEffect {

    public MagicEffectBridge(MGEF adapting) {
        super(adapting);
    }

    @Override
    public Set<Keyword> getKeywords() {
        Collection<FormID> keyWordFormIds = getRawObject().getKeywordSet().getKeywordRefs();
        Collection<Keyword> keyWords = getFinderFactory().createKeywordFinder().find(keyWordFormIds);

        return Collections.unmodifiableSet(new HashSet<>(keyWords));
    }

    @Override
    public void addKeyword(Keyword keyword) {
        getRawObject().getKeywordSet().addKeywordRef(keyword.getForm());
    }

    @Override
    public void removeKeyword(Keyword keyword) {
        getRawObject().getKeywordSet().removeKeywordRef(keyword.getForm());
    }

    @Override
    public boolean getFlag(SpellEffectFlag flag) {
        return getRawObject().get(flag);
    }

    @Override
    public void setFlag(SpellEffectFlag flag) {
        getRawObject().set(flag, true);
    }

    @Override
    public void unsetFlag(SpellEffectFlag flag) {
        getRawObject().set(flag, false);
    }

    @Override
    public JSkyScriptPackage getScriptPackage() {
        ScriptPackage scriptPackage = getRawObject().getScriptPackage();
        return getBridgeFactory().createBridge(scriptPackage);
    }

    @Override
    public float getBaseCost() {
        return getRawObject().getBaseCost();
    }

    @Override
    public void setBaseCost(float cost) {
        getRawObject().setBaseCost(cost);
    }

    @Override
    public Major getRelated() {
        FormID id = getRawObject().getRelatedID();
        return getFinderFactory().createMajorFinder().find(id);
    }

    @Override
    public void setRelated(Major related) {
        FormID id = getIdProducer().produce(related);
        getRawObject().setRelatedID(id);
    }

    @Override
    public ActorValue getSkillType() {
        return getRawObject().getSkillType();
    }

    @Override
    public void setSkillType(ActorValue val) {
        getRawObject().setSkillType(val);
    }

    @Override
    public ActorValue getResistanceValue() {
        return getRawObject().getResistanceAV();
    }

    @Override
    public void setResistanceValue(ActorValue val) {
        getRawObject().setResistanceAV(val);
    }

    @Override
    public Light getLight() {
        throw new UnsupportedOperationException("Light unsupported");
    }

    @Override
    public void setLight(Light light) {
        FormID id = getIdProducer().produce(light);
        getRawObject().setLight(id);
    }

    @Override
    public float getTaperWeight() {
        return getRawObject().getTaperWeight();
    }

    @Override
    public void setTaperWeight(float value) {
        getRawObject().setTaperWeight(value);
    }

    @Override
    public EffectShader getHitShader() {
        FormID id = getRawObject().getHitShader();
        return getFinderFactory().createEffectShaderFinder().find(id);
    }

    @Override
    public void setHitShader(EffectShader hitShader) {
        FormID id = getIdProducer().produce(hitShader);
        getRawObject().setHitShader(id);
    }

    @Override
    public EffectShader getEnchantmentShader() {
        FormID id = getRawObject().getEnchantShader();
        return getFinderFactory().createEffectShaderFinder().find(id);
    }

    @Override
    public void setEnchantmentShader(EffectShader enchantShader) {
        FormID id = getIdProducer().produce(enchantShader);
        getRawObject().setEnchantShader(id);
    }

    @Override
    public int getMinSkillLevel() {
        return getRawObject().getSkillLevel();
    }

    @Override
    public void setMinSkillLevel(int level) {
        getRawObject().setSkillLevel(level);
    }

    @Override
    public int getArea() {
        return getRawObject().getArea();
    }

    @Override
    public void setArea(int area) {
        getRawObject().setArea(area);
    }

    @Override
    public float getCastingTime() {
        return getRawObject().getCastingTime();
    }

    @Override
    public void setCastingTime(float time) {
        getRawObject().setCastingTime(time);
    }

    @Override
    public float getTaperCurve() {
        return getRawObject().getTaperCurve();
    }

    @Override
    public void setTaperCurve(float value) {
        getRawObject().setTaperCurve(value);
    }

    @Override
    public float getTaperDuration() {
        return getRawObject().getTaperDuration();
    }

    @Override
    public void setTaperDuration(float value) {
        getRawObject().setTaperDuration(value);
    }

    @Override
    public float getSecondAVWeight() {
        return getRawObject().getSecondAVWeight();
    }

    @Override
    public void setSecondAVWeight(float value) {
        getRawObject().setSecondAVWeight(value);
    }

    @Override
    public int getEffectType() {
        return Math.round(getRawObject().getEffectType());
    }

    @Override
    public void setEffectType(int value) {
        getRawObject().setEffectType(value);
    }

    @Override
    public ActorValue getPrimaryAssocItem() {
        return getRawObject().getPrimaryAV();
    }

    @Override
    public void setPrimaryAssocItem(ActorValue val) {
        getRawObject().setPrimaryAV(val);
    }

    @Override
    public Projectile getProjectile() {
        FormID id = getRawObject().getProjectile();
        return getFinderFactory().createProjectileFinder().find(id);
    }

    @Override
    public void setProjectile(Projectile projectile) {
        FormID id = getIdProducer().produce(projectile);
        getRawObject().setProjectile(id);
    }

    @Override
    public Explosion getExplosion() {
        FormID id = getRawObject().getExplosion();
        return getFinderFactory().createExplosionFinder().find(id);
    }

    @Override
    public void setExplosion(Explosion explosion) {
        FormID id = getIdProducer().produce(explosion);
        getRawObject().setExplosion(id);
    }

    @Override
    public CastType getCastType() {
        return getRawObject().getCastType();
    }

    @Override
    public void setCastType(CastType cast) {
        getRawObject().setCastType(cast);
    }

    @Override
    public DeliveryType getDeliveryType() {
        return getRawObject().getDeliveryType();
    }

    @Override
    public void setDeliveryType(DeliveryType del) {
        getRawObject().setDeliveryType(del);
    }

    @Override
    public skyproc.genenums.ActorValue getSecondAssocItem() {
        return getRawObject().getSecondAV();
    }

    @Override
    public void setSecondAssocItem(ActorValue val) {
        getRawObject().setSecondAV(val);
    }

    @Override
    public Art getCastingArt() {
        FormID id = getRawObject().getCastingArt();
        return getFinderFactory().createArtFinder().find(id);
    }

    @Override
    public void setCastingArt(Art art) {
        FormID id = getIdProducer().produce(art);
        getRawObject().setCastingArt(id);
    }

    @Override
    public Art getHitEffectArt() {
        FormID id = getRawObject().getHitEffectArt();
        return getFinderFactory().createArtFinder().find(id);
    }

    @Override
    public void setHitEffectArt(Art art) {
        FormID id = getIdProducer().produce(art);
        getRawObject().setHitEffectArt(id);
    }

    @Override
    public ImpactSet getImpactData() {
        FormID id = getRawObject().getImpactData();
        return getFinderFactory().createImpactSetFinder().find(id);
    }

    @Override
    public void setImpactData(ImpactSet data) {
        FormID id = getIdProducer().produce(data);
        getRawObject().setImpactData(id);
    }

    @Override
    public float getSkillUsageMult() {
        return getRawObject().getSkillUsageMult();
    }

    @Override
    public void setSkillUsageMult(float mult) {
        getRawObject().setSkillUsageMult(mult);
    }

    @Override
    public DualCastArt getDualCast() {
        FormID id = getRawObject().getDualCast();
        return getFinderFactory().createDualCastArtFinder().find(id);
    }

    @Override
    public void setDualCast(DualCastArt art) {
        FormID id = getIdProducer().produce(art);
        getRawObject().setDualCast(id);
    }

    @Override
    public float getDualCastScale() {
        return getRawObject().getDualCastScale();
    }

    @Override
    public void setDualCastScale(float scale) {
        getRawObject().setDualCastScale(scale);
    }

    @Override
    public Art getEnchantArt() {
        FormID id = getRawObject().getEnchantArt();
        return getFinderFactory().createArtFinder().find(id);
    }

    @Override
    public void setEnchantArt(Art art) {
        FormID id = getIdProducer().produce(art);
        getRawObject().setEnchantArt(id);
    }

    @Override
    public Spell getEquipAbility() {
        FormID id = getRawObject().getEquipAbility();
        return getFinderFactory().createSpellFinder().find(id);
    }

    @Override
    public void setEquipAbility(Spell spell) {
        FormID id = getIdProducer().produce(spell);
        getRawObject().setEquipAbility(id);
    }

    @Override
    public ImageSpaceMod getImageSpaceMod() {
        FormID id = getRawObject().getImageSpaceMod();
        return getFinderFactory().createImageSpaceModFinder().find(id);
    }

    @Override
    public void setImageSpaceMod(ImageSpaceMod imageSpaceMod) {
        FormID id = getIdProducer().produce(imageSpaceMod);
        getRawObject().setImageSpaceMod(id);
    }

    @Override
    public Perk getPerk() {
        FormID id = getRawObject().getPerk();
        return getFinderFactory().createPerkFinder().find(id);
    }

    @Override
    public void setPerk(Perk perk) {
        FormID id = getIdProducer().produce(perk);
        getRawObject().setPerk(id);
    }

    @Override
    public SoundVolume getSoundVolume() {
        return getRawObject().getSoundVolume();
    }

    @Override
    public void setSoundVolume(SoundVolume vol) {
        getRawObject().setSoundVolume(vol);
    }

    @Override
    public float getScriptAIDataScore() {
        return getRawObject().getScriptAIDataScore();
    }

    @Override
    public void setScriptAIDataScore(float score) {
        getRawObject().setScriptAIDataScore(score);
    }

    @Override
    public float getScriptAIDataTime() {
        return getRawObject().getScriptAIDataTime();
    }

    @Override
    public void setScriptAIDataTime(float score) {
        getRawObject().setScriptAIDataTime(score);
    }

    @Override
    public Collection<Condition> getConditions() {
        List<Condition> result = getRawObject().getConditions();
        return Collections.unmodifiableList(result);
    }

    @Override
    public void addCondition(Condition condition) {
        getRawObject().addCondition(condition);
    }

    @Override
    public void removeCondition(Condition condition) {
        getRawObject().removeCondition(condition);
    }
}
